<?php
//No direct access
defined('_JEXEC') or die('Restricted access');
$priceformat = OwnserviceHelper::getParams('price_format', '#,###.##');
$dateformat  = OwnserviceHelper::getParams('date_format', '%d/%m/%Y'); 
?>
<div id="ownservices">
	<div id="mainmenuownservice"><?php echo MenuHelper::nav(); ?></div>
	<div id="mainownservice">
		<h3><?php echo JText::_('OWNSERVICE_TRANSFER_MONEY_HISTORY'); ?></h3>
		<hr />
		<form action="<?php echo JRoute::_('index.php'); ?>" method="post" name="adminForm">
		<table>
			<tr>
				<td width="100%"></td>
				<td nowrap="nowrap">
					<?php echo $this->lists['account']; ?>
					<?php echo $this->lists['status']; ?>
				</td>
			</tr>
		</table>
		<table class="adminlist" cellspacing="1">
		<tr>
			<td align="center" class="tablelist"><?php echo JText::_('OWNSERVICE_RECEIVER_NO'); ?></td>
			<td align="center" class="tablelist"><?php echo JText::_('OWNSERVICE_ACCOUNT_NAME'); ?></td>
			<td align="center" class="tablelist"><?php echo JText::_('OWNSERVICE_ACCOUNT_NO'); ?></td>
			<td align="center" class="tablelist"><?php echo JText::_('Date'); ?></td>
			<td align="center" class="tablelist"><?php echo JText::_('OWNSERVICE_TRANSFER_ON'); ?></td>
			<td align="center" class="tablelist"><?php echo JText::_('OWNSERVICE_STATUS'); ?></td>
			<td align="center" class="tablelist"><?php echo JText::_('OWNSERVICE_AMOUNT_TRANSFER'); ?><br />
			(AUD)</td>
			<td align="center" class="tablelist"><?php echo JText::_('OWNSERVICE_RATE'); ?><br />
			<?php echo $this->profile->currency; ?></td>
			<td align="center" class="tablelist"><?php echo JText::_('OWNSERVICE_TOTAL_EXCHANGE'); ?><br />
			<?php echo $this->profile->currency; ?></td>
			<td align="center" class="tablelist"><?php echo JText::_('OWNSERVICE_FEE'); ?><br />
			(AUD)</td>
		</tr>
		<?php
			$k =0;
			$total_amount = 0;
			$total_transfer = 0;
			$total_fee = 0;
			for($i=0,$n=count($this->rows);$i<$n;$i++): 
			$row = $this->rows[$i];
		?>
		<tr class="<?php echo "row$k"; ?>">
			<td align="center" class="inner_tablelist"><?php echo $row->transactionid; ?></td>
			<td align="center" class="inner_tablelist"><?php echo $row->account_name; ?></td>
			<td align="center" class="inner_tablelist"><?php echo OwnserviceHelper::accountFormat($row->account); ?></td>
			<td align="center" class="inner_tablelist"><?php echo JHTML::_('date', $row->created, $dateformat); ?></td>
			<td align="center" class="inner_tablelist">
				<?php 
					echo ($row->requested_date != $this->nullDate)?JHTML::_('date', $row->requested_date, $dateformat):'';
				?>
			</td>
			<td align="center" class="inner_tablelist"><?php echo OwnserviceHelper::getStatus($row->id, $row->state); ?></td>
			<td class="inner_tablelist" align="center"><?php echo OwnserviceHelper::moneyFormat($priceformat,$row->amount); ?></td>
			<td class="inner_tablelist" align="center">
				<?php
					$color = '';
					if($row->extrarate > 0.00) {
						$color = 'red';
					} else if($row->extrarate < 0.00) {
						$color = 'green';
					}
					if(!$row->iscore){
						$row->rate = $row->real_rate;
					}
				?>
				<span class="<?php echo $color; ?>"><?php echo OwnserviceHelper::moneyFormat($priceformat,$row->rate+$row->extrarate); ?></span>
			</td>
			<td class="inner_tablelist" align="center">
				<?php
					$color = '';
					$total = 0;
					if($row->extratotal > 0.00) {
						$color = 'red';
						$total = $row->extratotal;
					} else {
						$total = $row->amount * ($row->rate+$row->extrarate);
					}
				?>
				<span class="<?php echo $color; ?>">
					<?php echo OwnserviceHelper::moneyFormat($priceformat,($total- ($row->bankfee+$row->extrabfee))); ?>
				</span>
			</td>
			<td class="inner_tablelist" align="center"><?php echo OwnserviceHelper::moneyFormat($priceformat,$row->fee); ?></td>
		</tr>
		<?php
			$total_amount 	= $total_amount + $row->amount;
			$total_fee		= $total_fee + $row->fee;
			$total_transfer = $total_transfer+ ($total- ($row->bankfee+$row->extrabfee));
			$k = 1 - $k; endfor; 
		?>
		<tr> 
		  <td colspan="6" align="right"><strong><?php echo JText::_('OWNSERVICE_TOTAL'); ?></strong></td>
		  <td align="center"><u><strong><?php echo OwnserviceHelper::moneyFormat($priceformat,$total_amount); ?></u></strong></td>
		  <td align="center"></td>
		  <td align="center"><strong><u><?php echo OwnserviceHelper::moneyFormat($priceformat,$total_transfer); ?></u></strong></td>
		  <td align="center"><strong><u><?php echo OwnserviceHelper::moneyFormat($priceformat,$total_fee); ?></u></strong></td>
		</tr>
		</table>
		<table width="100%" cellpadding="0" cellspacing="0" style="margin-top:10px;">
		<tr>
			<td align="center"><input type="button" name="back" value="<?php echo JText::_('OWNSERVICE_BACK'); ?>" onClick="javascript: submitbutton('cancel');" /></td>
		</tr>
		</table>
		<input type="hidden" name="option" value="com_ownservice" />
		<input type="hidden" name="controller" value="ownservice" />
		<input type="hidden" name="boxchecked" value="0" />
		<input type="hidden" name="task" value="" />
		<input type="hidden" name="view" value="history" />
		<input type="hidden" name="filter_order" value="<?php echo $this->lists['order']; ?>" />
		<input type="hidden" name="filter_order_Dir" value="<?php echo $this->lists['order_Dir']; ?>" />
		<?php echo JHTML::_( 'form.token' ); ?>
		</form>
	</div>
</div>